package Database;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.PreparedStatement;
import java.sql.ResultSet;

import javax.swing.JOptionPane;

public class CheckBookInBase {
	boolean CheckBook = false;
	public CheckBookInBase(String idBook)
	{
		try{
			Class.forName("com.mysql.jdbc.Driver");
			Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/library_community","root","1234");
			PreparedStatement statement = con.prepareStatement("select BOOK_ID from lcmm_book where ( '" + idBook + "' = BOOK_ID)");
			ResultSet result = statement.executeQuery();
			if(result.next())
			{
				CheckBook = true;
			}
			result.close();
			statement.close();
			con.close();
		}catch (Exception e) {
			JOptionPane.showMessageDialog(null, e);
		}
	}
	public boolean getCheckBookInBase()
	{
		return CheckBook;
	}
}
